class Tag < ActiveRecord::Base
  named_scope :used, :conditions => "count > 0", :order => "count desc"  
  
  has_and_belongs_to_many :blog_posts, :join_table   => "tagged_items", :association_foreign_key  => "taggable_id"
  has_and_belongs_to_many :projects, :join_table   => "tagged_items", :association_foreign_key  => "taggable_id"
  has_and_belongs_to_many :milestones, :join_table   => "tagged_items", :association_foreign_key  => "taggable_id"
                            
  before_save  :update_stub_name
  
  def update_stub_name
    self.stub_name = self.name.parameterize.to_s
  end
  
end
